import formContainers from './components/form-container/container';
import formRunTime from './components/form-render/runtime';
import formItems from './components/form-item/item';
import basicComponent from './components/form-basic/basic'

import FormDesigner from './components/designer/FormDesigner.vue'
import FormRenderer from './components/render/FormRenderer.vue'
import type { App } from 'vue'

// 导出插件
export default {
  install(app: App) {
    
    Object.entries(formContainers).forEach(([name, comp]) => {
      app.component(name, comp); // 全局注册所有容器组件
    });
    Object.entries(formItems).forEach(([name, comp]) => {
      app.component(name, comp); // 全局注册所有字段组件
    });
    Object.entries(basicComponent).forEach(([name, comp]) => {
      app.component(name, comp); // 全局注册所有基础组件
    });
    Object.entries(formRunTime).forEach(([name, comp]) => {
      app.component(name, comp); // 全局注册所有运行组件
    });

    if (typeof window !== 'undefined' && !window.__WORKFOX_LOGO_PRINTED__) {
      console.log(
        `%c WorkfoxFormGennerator v1.1.5\n%c https://gitee.com/xbos1314/workfox-form-generator`,
        'color: #42b983; font-size: 16px; font-weight: bold;',
        'color: #999; font-size: 12px;'
      )
      window.__WORKFOX_LOGO_PRINTED__ = true
    }
    
    app.component('FormDesigner', FormDesigner)
    app.component('FormRenderer', FormRenderer)
  }
}